package com.fruit.dao.fruit;

import com.fruit.bean.entity.fruit.FruitUserOrderInfo;
import com.fruit.dao.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface FruitUserOrderRepository extends BaseRepository<FruitUserOrderInfo, Long> {
    /**
     * 根据商品id获取订单数量（即对应产品的销售量）
     * @param fruitShelfId 商品id
     * @return
     */
    @Query(nativeQuery = true, value = "select count(*) from f_user_order_info where fruit_shelf_id = ?1")
    Integer countOrderNumberByShelfId(Long fruitShelfId);

    /**
     * 获取所有没有收货的订单
     * @return 订单列表
     */
    @Query(nativeQuery = true, value = "select * from f_user_order_info " +
            "where user_order_status = ?1 " +
            "or user_order_status = ?2")
    List<FruitUserOrderInfo> queryUnRecievedOrder(Integer paid,Integer transform);
}
